package textures;

import hulppakket.Color3f;
import hulppakket.TexCoord2f;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class Texture {

	private String name;
	private BufferedImage image;

	public Texture(String path, String name) throws IOException {
		this.name = name;
    	this.image = ImageIO.read(new File("src/XML/"+path));
	}

	public String getName() {
		return this.name;
	}

	public BufferedImage getImage() {
		return this.image;
	}

	public Color3f getColor(TexCoord2f point) {
		int x = (int) (point.x * this.image.getWidth()-1);
		int y = (int) (point.y * this.image.getHeight()-1);
		Color color = new Color(this.image.getRGB(x, y));
		Color3f result = new Color3f();
		result.set(color);
		return result;
	}
}
